<?php

class Payments extends HTech_Db_Table
{
    protected $_name    = 'view_payments';
    protected $_primary = 'PaymentId';
    
    protected $_referenceMap    = array(
        'Loans' => array(
            'columns'           => array('LoanId'),
            'refTableClass'     => 'Loans',
            'refColumns'        => array('LoanId')
        ),
        'Receipts' => array(
            'columns'           => array('ReceiptId'),
            'refTableClass'     => 'Receipts',
            'refColumns'        => array('ReceiptId')
        ),
        'LoanWriteOffs' => array(
            'columns'           => array('LoanId'),
            'refTableClass'     => 'LoanWriteOffs',
            'refColumns'        => array('LoanId')
        )
    );  
    
    protected function _setGridMetadata()
    {
        $this->_gridMetadata['title'] = $this->translate("Payments");
        $this->_gridMetadata['params'] = array('LoanMasterId', 'LoanId', 'ClientId', 'LocationId','UserId');
        $this->_gridMetadata['onClick'] = 'loan.payment.view';
        $this->_gridMetadata['headers'] = array
            (
                array('PaymentId',                80, $this->translate("Id"),                       'Number'),
                array('LoanId',                   80, $this->translate("Loan"),                     'Number'),
                array('ReceiptId',                80, $this->translate("Receipt"),                  'Number'),
                array('Date',                     80, $this->translate("Disb. date"),               'DateTime', 'Date'),
                array('Pmt',                      80, $this->translate("Pmt"),                      'Number',   'Standard'),
                array('Penalties',                80, $this->translate("Penalties"),                'Number',   'Standard'),
                array('Delay',                    80, $this->translate("Delay"),                    'Number'),
                array('Interest',                 80, $this->translate("Interest"),                 'Number',   'Standard'),
                array('LoanInsurance',            80, $this->translate("LoanInsurance"),            'Number',   'Standard'),
                array('HealthInsurance',          80, $this->translate("HealthInsurance"),          'Number',   'Standard'),
                array('AdministrativeFee',        80, $this->translate("AdministrativeFee"),        'Number',   'Standard'),
                array('Principal',                80, $this->translate("Principal"),                'Number',   'Standard'),
                array('BalancePrincipal',         80, $this->translate("BalancePrincipal"),         'Number',   'Standard'),
                array('BalanceLoanInsurance',     80, $this->translate("BalanceLoanInsurance"),     'Number',   'Standard'),
                array('BalanceHealthInsurance',   80, $this->translate("BalanceHealthInsurance"),   'Number',   'Standard'),
                array('BalanceAdministrativeFee', 80, $this->translate("BalanceAdministrativeFee"), 'Number',   'Standard'),
                array('Special',                  80, $this->translate("Special"),                  'String'),
                array('TransactionId',            80, $this->translate("TransactionId"),            'Number'),
                array('Username',                 80, $this->translate("Username"),                 'String')
            );
        return $this;
    }
}